/******************* 公共变量 *******************/
var inviteObj = core.ls('inviteObj', 'o') || {},
	permissionObj = core.ls('permissionObj', 'o') || {};
!inviteObj.users && (inviteObj.users = []);

/******************* 载入本地存储数据 *******************/
if (permissionObj.who_see) {
	permissionObj.who_see && $('html body .wrap .invite-permission section div[who_see="' + permissionObj.who_see + '"]').addClass('active');
} else if (inviteObj.who_see) {
	inviteObj.who_see && $('html body .wrap .invite-permission section div[who_see="' + inviteObj.who_see + '"]').addClass('active');
} else {
	$('html body .wrap .invite-permission section div').eq(0).addClass('active');
	permissionObj.who_see = '1';
}

/******************* 是否公开功能选择 *******************/
core.tabSwitch({
	tit: 'html body .wrap .invite-permission section div',
	active: false
}, function ($this, thisIndex, $thisCon, beforeIndex, isInit) {
	if (!isInit) {
		permissionObj.who_see = $this.attr('who_see');
		core.ls('permissionObj', 'o', permissionObj);
		if (thisIndex) {
			core.href(chooseContact + '?who_see=' + (thisIndex + 1));
		}
	}
});

/******************* 保存 *******************/
$('html body .wrap .invite-permission .btn').on('tap', function () {
	$.extend(inviteObj, permissionObj);
	core.ls('inviteObj', 'o', inviteObj);
	core.lsDel('permissionObj', 'remove');
	core.back();
});

/******************* 返回按钮 *******************/
common.beforeBack = function () {
	core.lsDel('permissionObj', 'remove');
}
